<!--
  ~ Copyright (c) 2019. seven studio. @chengdu
  ~ seven studio in chengdu by lb
  ~ this project for snmp tool
  -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加阈值</title>
    <link rel="stylesheet" href="/res/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/res/frame/static/css/style.css">
    <link rel="icon" href="/res/frame/static/image/code.png">
</head>
<body class="body">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px">阈值名称:</label>
        <div class="layui-input-inline">
            <input type="text" id='conName' placeholder="阈值名称" lay-verify="required"
                   class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px">入网最大速率:</label>
        <div class="layui-input-inline">
            <input type="text" id='conOutMaxRate' placeholder="入网最大速率" lay-verify="required"
                   class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px">入网最小速率:</label>
        <div class="layui-input-inline">
            <input type="text" id='conInMinRate' placeholder="入网最小速率" lay-verify="required"
                   class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px ">出网最大速率:</label>
        <div class="layui-input-inline">
            <input type="text" id='conInMaxRate' placeholder="出网最大速率" lay-verify="required"
                   class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:100px ">出网最小速率:</label>
        <div class="layui-input-inline">
            <input type="text" id='conOutMinRate' placeholder="出网最小速率" lay-verify="required"
                   class="layui-input" autocomplete="off">
        </div>
    </div>

</form>

<div class="layui-layer-btn layui-layer-btn-c">
    <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" id="sub">提交</button>
</div>


<script src="/res/frame/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/res/js/index.js"></script>
<script type="text/javascript">

    layui.use(['form', 'layedit', 'laydate', 'element', 'cookie'], function () {


        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            , $ = layui.jquery,
            cookie = layui.cookie,
            laydate = layui.laydate;

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
        var conType = GetQueryString("conType")
        $('#sub').on('click', function () {
            var params={
                "conType":conType,
                "conName": $("#conName").val(),
                "conOutMaxRate": $("#conOutMaxRate").val(),
                "conInMinRate": $("#conInMinRate").val(),
                "conInMaxRate": $("#conInMaxRate").val(),
                "conOutMinRate": $("#conOutMinRate").val(),
                "conCreateMName": $.cookie('adminName'),
                "conCreateMId": $.cookie('adminId'),
            }

            if(conType=="PORT"){
                params.conPortId = GetQueryString("id");
            }else {
                params.conDevId=GetQueryString("id");
            }

            $.ajax({
                url: "/con/add",
                type: "post",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (result) {
                    console.log(result)
                    if (result.code == 200) {
                        layer.msg(result.msg);
                        setTimeout(function () {
                            parent.location.reload();
                        }, 1000);
                    } else {
                        layer.msg(result.msg);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest.responseText);
                }
            });
        });


    });


</script>
</body>
</html>